package com.forum.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.forum.demo.model.Message;
import com.forum.demo.model.response.MessageResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageMapper extends BaseMapper<Message> {
    @Select("select nickname,message.id,content,post_user_id,receive_user_id,\n" +
            "message.state,message.create_time,message.update_time\n" +
            "from message, user_info\n" +
            "where message.post_user_id = user_info.id\n" +
            "and message.delete_state = 0\n" +
            "and message.receive_user_id = #{receiveUserId}\n" +
            "order by message.create_time desc")
    public List<MessageResponse> selectByReceiveUserId(Long postUserId);
}
